package com.guochu.pro.service.impl;

import com.guochu.pro.entity.Complaint;
import com.guochu.pro.dao.ComplaintDao;
import com.guochu.pro.service.ComplaintService;
import com.guochu.utils.Pagination;
import com.guochu.common.infrastructure.IService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 视频表(Complaint)表服务实现类
 *
 * @author makejava
 * @since 2021-11-10 22:45:05
 */
@Service
public class ComplaintServiceImpl extends IService implements ComplaintService {
    @Resource
    private ComplaintDao complaintDao;

    /**
     * 新增数据
     *
     * @param complaint 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(Complaint complaint) {
        this.create(complaint);
        return this.complaintDao.insert(complaint);
    }
    
    /**
     * 修改数据
     *
     * @param complaint 实例对象
     * @return 实例对象
     */
    @Override
    public int update(Complaint complaint) {
        return this.complaintDao.update(complaint);
    }
    
    /**
     * 逻辑删除多条记录
     *
     * @param idList 主键
     * @return
     */
    @Override
    public int removeByIds(List<String> idList) {
        return this.complaintDao.removeByIds(idList);
    }
    
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Complaint queryById(String id) {
        return this.complaintDao.queryById(id);
    }

    /**
     * 根据条件查询分页数据
     *
     * @param pagination 分页条件
     * @param limit 查询条件
     * @return 分页数据
     */
    @Override
    public List<Complaint> queryPageByLimit(Pagination pagination, Map<String, Object> limit){
        pagination.setTotal(this.complaintDao.recordCount(limit));
        limit.put("offset", (pagination.getCurrentPage() - 1) * pagination.getPageSize());
        limit.put("pageSize", pagination.getPageSize());
        return this.complaintDao.queryPageByLimit(limit);
    }
    
    /**
     * 根据条件查询全部数据
     *
     * @param limit 查询条件
     * @return 所有数据
     */
    @Override
    public List<Complaint> queryAllByLimit(Map<String, Object> limit) {
        return this.complaintDao.queryAllByLimit(limit);
    }
}
